const express = require('express')
const app = express()
const bodyParser = require('body-parser') //用来获取post传来的参数
const vipLogin = require('./data/vip_login.json')
const admianLogin = require('./data/admian_login.json')
const fail = require('./data/fai_sb.json')
const url = require("url")
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
app.get('/login', (req, res) => {
    const user = url.parse(req.url,true).query.user
    console.log(url,'urlurlurlurlurlurl')
    if(user === 'admian') {
        res.send(admianLogin)
    }

})
app.post('/login',  (req, res) =>{
    const user = req.body.username
    const password = req.body.userpassword
    if(user === 'admian' && password === '123'){
        res.send(admianLogin)
    }else {
        res.send(fail)
    }
})

app.listen(3300, () => {
    console.log('服务器运行在3300')
})